﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class PaymentSuccessful : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["SubcribleType"] != null && Session["customer"] != null)
        {
            bussiness bus = new bussiness();
            Customer c = (Customer)Session["customer"];
            SubcribleType sct = (SubcribleType)Session["SubcribleType"];
            int month = 0;
            bus.updateCustomerStatus(c.CustomerId);
            if(sct.SubcribleName == "1month")
            {
                month = 1;
            }
            if(sct.SubcribleName == "3month")
            {
                month = 3;
            }
            if(sct.SubcribleName == "6month")
            {
                month = 6;
            }
            if(sct.SubcribleName == "12month")
            {
                month = 12;
            }
            bus.insertSubcrible(c.CustomerId, DateTime.Now.AddMonths(month), sct.SubcribleTypeId);
            Session["customer"] = bus.getCustomerById(c.CustomerId);
            Response.Redirect("ProfileCustomer.aspx");
        }
        else
        {
            Response.Redirect("PaymentError.aspx");
        }
    }
}